/**
 * 配置
 * */
package org.zmhhxl.api.auth;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.zmhhxl.api.auth.domain.entity.UserInfo;
import org.zmhhxl.api.auth.factory.RemoteUserServiceFallbackFactory;
import org.zmhhxl.common.core.domain.Result;

import java.util.Optional;

/**
 * 远程接口不要被服务器端调用,只应该在客户端被调用
 * */
@FeignClient(name = "remoteUserInfoService", url = "http://127.0.0.1:8082",
            contextId = "remoteUserInfoService", fallbackFactory = RemoteUserServiceFallbackFactory.class)
public interface RemoteUserInfoService {

   @GetMapping("/user/find_by_username/{username}")
    Result<Optional<UserInfo>> findByUsername(@PathVariable("username") String username);

   @GetMapping("/user/find_by_id/{userId}")
    Optional<UserInfo> findById(@PathVariable("userId") Long userId);

//   @PostMapping("/user/register")
//    UserInfo save(@RequestBody(required = false) UserInfo userInfo);  //@RequestBody @SpringQueryMap @PathVariable @RequestParam

   @PutMapping("/user/record_login_user")
   void recordLoginUser(@RequestBody(required = false) UserInfo userInfo);
}
